package com.example.day02.controller;

import com.example.day02.pojo.User;
import com.example.day02.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/add")
    public String add(@RequestBody User user){
        return userService.add(user);
    }

    @GetMapping("/findAll")
    public List<User> findAll(){
        return userService.findAll();
    }

    @PostMapping("/edit")
    public String edit(@RequestBody User user){
        return userService.edit(user);
    }

    @PostMapping("/delete")
    public String delete(Integer id){
        return userService.delete(id);
    }
}
